package com.credit.mola.app.adapter

import android.view.View
import android.widget.RelativeLayout
import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.RecyclerView
import com.credit.mola.lib_baseadapter.SikadwaRecyclerViewAdapter
import com.credit.mola.lib_baseadapter.SikadwaViewHolderHelper
import com.credit.mola.app.R
import org.json.JSONObject

/**
 * Sikadwa
 * @Author wwdeng
 * @CreateTime: 2024/4/24 14:42
 * @Annotation：贷款申请适配器
 */
class CreditApplyDaysAdapter(recyclerView: RecyclerView?) :
    SikadwaRecyclerViewAdapter<JSONObject>(recyclerView, R.layout.item_credit_apply_days) {
    override fun setItemChildListener(helper: SikadwaViewHolderHelper, viewType: Int) {
        helper.setItemChildClickListener(R.id.itemLayout) //点击Item
    }

    override fun fillData(helper: SikadwaViewHolderHelper, position: Int, model: JSONObject) {
        val textDay = helper.getTextView(R.id.textDay)
        textDay.text = model.optString("day")

        val itemLayout = helper.getView<RelativeLayout>(R.id.itemLayout)
        if (model.optBoolean("isSelect",false)){
            itemLayout.setBackgroundResource(R.drawable.radius_fill_ff4c8ffb_12)
            textDay.setTextColor(ContextCompat.getColor(mContext,R.color.white))
            helper.setVisibility(R.id.imgSelect,View.VISIBLE)
        } else {
            itemLayout.setBackgroundResource(R.drawable.radius_fill_ffcfdbee_12)
            textDay.setTextColor(ContextCompat.getColor(mContext,R.color.FF92ABD3))
            helper.setVisibility(R.id.imgSelect,View.GONE)
        }
    }
}